import axios from 'axios'
import baseUrl from '@/baseUrl'
export default {
  name: 'mContent',
  created () {
    this.getDataList()
  },
  watch: {
    $route: 'getDataList'
  },
  data () {
    return {
      datalist: [],
      nav: {
        newsList: '新闻公告',
        zxxw: '最新新闻',
        rmxw: '热门新闻',
        tzgg: '通知公告',
        hyzx: '行业资讯'
      }
    }
  },
  computed: {
    headTitle () {
      return `${this.nav[[this.$route.name]]}>${this.nav[[this.$route.params.title]]}`
    }
  },
  methods: {
    toDetail (id) {
      // this.$router.push(`/details/${id}`)
      this.$router.push({ name: 'details', params: { id: id, routerDetail: this.$route.path } })
    },
    getDataList () {
      axios.get(`${baseUrl}${this.$route.path}`)
        .then((res) => {
          this.datalist = res.data
        })
    }
  }
}
